A Case For Sealing Classes In Java
نویسندگان
چکیده
It is a well-known fact that inheritance as defined in most existing object-oriented languages breaks encapsulation in a very subtle way. For instance, Java provides facilities for encapsulation both at the class-level and at the packagelevel. But it also introduces language constructs (such as public/ protected modifier and inheritance) that lets clients to access the internals of a class in a subtle way. In this paper we introduce the notion of class sealing in Java that selectively prevent clients of a package from accessing the internals of a class via inheritance. Class sealing allows extension of classes within a package, but prevent clients from extending such classes outside of the package. We will discuss three areas of application of class sealing: maintenance, security, and program optimization. We provide empirical evidence, collected from large bodies of real-life code, showing that sealed classes fit well within existing coding practice.
منابع مشابه
Quantitative Evaluation of the Lateral Sealing Ability of Normal Faults in Siliciclastic Sequences: Implication for Fault Trap in Well Gang 64, in the West Qikou Sag, China
The lateral sealing ability of a normal fault is a major factor in creating hydrocarbon traps. Therefore, a methodology for assessing the sealing ability of faults in the siliciclastic sequences of subsidence basins has been established; moreover, by using this methodology, the uncertainty inherent in hydrocarbon exploration can be decreased. Moreover, the petrophysical properties of fault roc...
متن کاملWriting Self-testing Java Classes with SelfTest
This document provides a tutorial introduction to Java annotations called SelfTest. The SelfTest annotations allow one to annotate Java classes with test data, and the SelfTest annotation processor generates executable JUnit test classes from annotated Java classes by translating test cases to executable JUnit tests. The SelfTest annotations not only automate unit testing of Java classes signif...
متن کاملJartege: A Tool for Random Generation of Unit Tests for Java Classes
This paper presents Jartege, a tool which allows random generation of unit tests for Java classes specified in JML. JML (Java Modeling Language) is a specification language for Java which allows one to write invariants for classes, and preand postconditions for operations. As in the JML-JUnit tool, we use JML specifications on the one hand to eliminate irrelevant test cases, and on the other ha...
متن کاملتأثیر آلودگی کانال ریشه دندان به بزاق بر مهر و موم اپیکالی
Introduction: Root canal obturation aims at sealing the root canal system to prevent re-contamination of canal and periapical space. Presence of moisture in canal before obturation may posit a negative effect on the quality of canal sealing. Therefore, this study was conducted to investigate the effect of canal contamination with saliva on apical microleakage. Methods: In this laboratory study...
متن کاملFramework for Prioritizing Solutions in Overcoming Data Quality Problems Using Analytic Hierarchy Process (AHP)
The Central Statistics Agency (BPS) is a government institution that has the authority to carry out statistical activities in the form of censuses and surveys, to produce statistical data needed by the government, the private sector and the general public, as a reference in planning, monitoring, and evaluation of development results. Therefore, providing quality statistical data is very decisiv...
متن کامل